home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_573 / plasma / plasma_32.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  17KB  |  625 lines

  1. /*************************************************
  2. /*
  3. /* This code © 1991 by W. Roger uzun
  4. /* This code is for Lattice 5.10x
  5. /* First assemble FastPix.asm by using Lattice asm
  6. /* compile using :
  7. /* lc -v -cf -Lit+FastPix.o -rr -m0 -O -tr -w Plasma_32 (for 68000 version)
  8. /* lc -v -cf -Lit+FastPix.o -rr -m2 -O -tr -dCPU020 Plasma_32 (for 68020 version)
  9. /*
  10. /*************************************************/
  11.  
  12. #define VIEW_MODES (LACE)
  13. #define NUM_COLORS 32
  14. /* #define CPU020 1 */
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <math.h>
  19. #include <proto/exec.h>
  20. #ifdef CPU020
  21. #include <exec/execbase.h>
  22. #endif
  23. #include <proto/intuition.h>
  24. #include <proto/graphics.h>
  25. #include <time.h>
  26. #include <proto/dos.h>
  27. #define HEIGHT 400L
  28. #define DEPTH 5
  29. #define WIDTH 320L
  30. #define rowoffset (WIDTH/8)
  31. #define MODULUS (0x20000L)
  32. #define C 13849
  33. #define A 25173
  34. #define randu2(x) (((seed = seed*A+C))%(x))
  35. #define unmap(x) (randu2(6)+rev_array[(x)])
  36. #ifdef LATTICE
  37. #define PROTOTYPES 1
  38. #endif
  39.  
  40. #ifndef LATTICE
  41. #define __regargs
  42. #endif
  43.  
  44. #ifdef DEBUG
  45. int temparray[64];
  46. #endif
  47.  
  48. #define WINDOWSIGNAL (1L<<(wG->UserPort->mp_SigBit))
  49.  
  50. #define PaletteColorCount 32
  51.  
  52. short __aligned nplanes = DEPTH;
  53. UBYTE __aligned *bp[DEPTH];
  54. short __aligned ytable[HEIGHT];
  55.  
  56. struct TextFont __aligned *myTextFont;
  57.  
  58. struct RastPort __aligned *rpG;
  59.  
  60. struct TextAttr TOPAZ80 = {
  61.     (STRPTR)"topaz.font",
  62.     TOPAZ_EIGHTY,0,0
  63. };
  64. struct NewScreen NewScreenStructure = {
  65.     0,0,    /* screen XY origin relative to View */
  66.     320,HEIGHT,    /* screen width and height */
  67.     DEPTH,    /* screen depth (number of bitplanes) */
  68.     0,1,    /* detail and block pens */
  69.     VIEW_MODES,    /* display modes for this screen */
  70.     CUSTOMSCREEN,    /* screen type */
  71.     &TOPAZ80,    /* pointer to default screen font */
  72.     "Plasma",    /* screen title */
  73.     NULL,    /* first in list of custom screen gadgets */
  74.     NULL    /* pointer to custom BitMap structure */
  75. };
  76.  
  77. #define NEWSCREENSTRUCTURE NewScreenStructure
  78.  
  79. USHORT __aligned Palette[] = {
  80.     0x000,    /* color #0 */
  81.     0x0a5,  /* color #6 */
  82.     0x0b4,  /* color #7 */
  83.     0x0c3,  /* color #8 */
  84.     0x0e1,  /* color #9 */
  85.     0x0f0,  /* color #10 */
  86.  
  87.     0x01f0,    /* color #11 */
  88.     0x03d0,    /* color #12 */
  89.     0x05b0,    /* color #13 */
  90.     0x0790,    /* color #14 */
  91.     0x0970,    /* color #15 */
  92.     0x0a50,    /* color #16 */
  93.     0x0B40,    /* color #17 */
  94.     0x0c30,    /* color #18 */
  95.     0x0e10,    /* color #19 */
  96.     0x0f00,    /* color #20 */
  97.  
  98.     0x0f01,    /* color #21 */
  99.     0x0d03,    /* color #22 */
  100.     0x0b05,    /* color #23 */
  101.     0x0907,    /* color #24 */
  102.     0x0709,    /* color #25 */
  103.     0x050a,    /* color #26 */
  104.     0x040b,    /* color #27 */
  105.     0x030c,    /* color #28 */
  106.     0x020d,    /* color #29 */
  107.     0x010e,    /* color #30 */
  108.     0x000f,  /* color #31 */
  109.     0x01f,    /* color #1 */
  110.     0x03d,    /* color #2 */
  111.     0x05b,    /* color #3 */
  112.     0x079,    /* color #4 */
  113.     0x097    /* color #5 */
  114. };
  115.  
  116. #define PALETTE Palette
  117.  
  118. struct IntuiText IText1 = {
  119.     3,1,JAM1,    /* front and back text pens, drawmode and fill byte */
  120.     0,0,    /* XY origin relative to container TopLeft */
  121.     &TOPAZ80,    /* font pointer or NULL for default */
  122.     "Quit",    /* pointer to text */
  123.     NULL    /* next IntuiText structure */
  124. };
  125.  
  126. struct MenuItem MenuItem2 = {
  127.     NULL,    /* next MenuItem structure */
  128.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  129.     80,8,    /* hit box width and height */
  130.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  131.     0,    /* each bit mutually-excludes a same-level Item */
  132.     (APTR)&IText1,    /* Item render  (IntuiText or Image or NULL) */
  133.     NULL,    /* Select render */
  134.     'Q',    /* alternate command-key */
  135.     NULL,    /* SubItem list */
  136.     MENUNULL    /* filled in by Intuition for drag selections */
  137. };
  138.  
  139. struct IntuiText IText2 = {
  140.     3,1,JAM1,    /* front and back text pens, drawmode and fill byte */
  141.     0,0,    /* XY origin relative to container TopLeft */
  142.     &TOPAZ80,    /* font pointer or NULL for default */
  143.     "About",    /* pointer to text */
  144.     NULL    /* next IntuiText structure */
  145. };
  146.  
  147. struct MenuItem MenuItem1 = {
  148.     &MenuItem2,    /* next MenuItem structure */
  149.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  150.     80,8,    /* hit box width and height */
  151.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  152.     0,    /* each bit mutually-excludes a same-level Item */
  153.     (APTR)&IText2,    /* Item render  (IntuiText or Image or NULL) */
  154.     NULL,    /* Select render */
  155.     'A',    /* alternate command-key */
  156.     NULL,    /* SubItem list */
  157.     MENUNULL    /* filled in by Intuition for drag selections */
  158. };
  159.  
  160. struct Menu Menu1 = {
  161.     NULL,    /* next Menu structure */
  162.     0,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  163.     63,0,    /* Menu hit box width and height */
  164.     MENUENABLED,    /* Menu flags */
  165.     "Project",    /* text of Menu name */
  166.     &MenuItem1    /* MenuItem linked list pointer */
  167. };
  168.  
  169. #define MenuList1 Menu1
  170.  
  171. struct NewWindow NewWindowStructure1 = {
  172.     0,0,    /* window XY origin relative to TopLeft of screen */
  173.     320,HEIGHT,    /* window width and height */
  174.     4,8,    /* detail and block pens */
  175.     VANILLAKEY|MENUPICK,    /* IDCMP flags */
  176.     SMART_REFRESH+BACKDROP+BORDERLESS+ACTIVATE,    /* other window flags */
  177.     NULL,    /* first gadget in gadget list */
  178.     NULL,    /* custom CHECKMARK imagery */
  179.     " ",    /* window title */
  180.     NULL,    /* custom screen pointer */
  181.     NULL,    /* custom bitmap */
  182.     5,5,    /* minimum width and height */
  183.     -1,-1,    /* maximum width and height */
  184.     CUSTOMSCREEN    /* destination screen type */
  185. };
  186.  
  187. SHORT BorderVectors1[] = {
  188.     0,0,
  189.     51,0,
  190.     51,41,
  191.     0,41,
  192.     0,0
  193. };
  194. struct Border Border1 = {
  195.     -1,-1,    /* XY origin relative to container TopLeft */
  196.     3,0,JAM1,    /* front pen, back pen and drawmode */
  197.     5,    /* number of XY vectors */
  198.     BorderVectors1,    /* pointer to XY vectors */
  199.     NULL    /* next border in list */
  200. };
  201.  
  202. struct IntuiText IText3 = {
  203.     3,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  204.     15,17,    /* XY origin relative to container TopLeft */
  205.     NULL,    /* font pointer or NULL for default */
  206.     "OK",    /* pointer to text */
  207.     NULL    /* next IntuiText structure */
  208. };
  209.  
  210. struct Gadget Gadget1 = {
  211.     NULL,    /* next gadget */
  212.     65,217,    /* origin XY of hit box relative to window TopLeft */
  213.     50,40,    /* hit box width and height */
  214.     NULL,    /* gadget flags */
  215.     RELVERIFY,    /* activation flags */
  216.     BOOLGADGET,    /* gadget type flags */
  217.     (APTR)&Border1,    /* gadget border or image to be rendered */
  218.     NULL,    /* alternate imagery for selection */
  219.     &IText3,    /* first IntuiText structure */
  220.     NULL,    /* gadget mutual-exclude long word */
  221.     NULL,    /* SpecialInfo structure */
  222.     NULL,    /* user-definable data */
  223.     NULL    /* pointer to user-definable data */
  224. };
  225.  
  226. #define GadgetList2 Gadget1
  227.  
  228. struct IntuiText IText5 = {
  229.     3,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  230.     40,114,    /* XY origin relative to container TopLeft */
  231.     NULL,    /* font pointer or NULL for default */
  232.     "By Roger Uzun",    /* pointer to text */
  233.     NULL    /* next IntuiText structure */
  234. };
  235.  
  236. struct IntuiText IText4a = {
  237.     3,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  238.     16,61,    /* XY origin relative to container TopLeft */
  239.     NULL,    /* font pointer or NULL for default */
  240.     "Press 'C' to Cycle",    /* pointer to text */
  241.     &IText5    /* next IntuiText structure */
  242. };
  243.  
  244. #ifndef CPU020
  245. struct IntuiText IText4 = {
  246.     3,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  247.     6,21,    /* XY origin relative to container TopLeft */
  248.     NULL,    /* font pointer or NULL for default */
  249.     "Plasma_32 Version 1.G",    /* pointer to text */
  250.     &IText4a    /* next IntuiText structure */
  251. };
  252. #else
  253. struct IntuiText IText4c = {
  254.     3,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  255.     35,41,    /* XY origin relative to container TopLeft */
  256.     NULL,    /* font pointer or NULL for default */
  257.     "68020 Edition",    /* pointer to text */
  258.     &IText4a    /* next IntuiText structure */
  259. };
  260. struct IntuiText IText4 = {
  261.     3,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  262.     6,21,    /* XY origin relative to container TopLeft */
  263.     NULL,    /* font pointer or NULL for default */
  264.     "Plasma_32 Version 1.G",    /* pointer to text */
  265.     &IText4c    /* next IntuiText structure */
  266. };
  267. #endif
  268.  
  269. struct NewWindow NewWindowStructure3 = {
  270.     70,30,    /* window XY origin relative to TopLeft of screen */
  271.     180,280,    /* window width and height */
  272.     0,1,    /* detail and block pens */
  273.     GADGETUP,    /* IDCMP flags */
  274.     SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  275.     &Gadget1,    /* first gadget in gadget list */
  276.     NULL,    /* custom CHECKMARK imagery */
  277.     " ",    /* window title */
  278.     NULL,    /* custom screen pointer */
  279.     NULL,    /* custom bitmap */
  280.     5,5,    /* minimum width and height */
  281.     -1,-1,    /* maximum width and height */
  282.     CUSTOMSCREEN    /* destination screen type */
  283. };
  284.  
  285.  
  286. struct Screen __aligned *sC;
  287. struct Window __aligned *wG;
  288. UWORD __aligned done=0;
  289.  
  290. long __aligned maparray[256]={5,1,1,1,1,1,2,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,/* 26 */
  291.             7,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,/* 43 */
  292.                     33,33,33,33,33,34,34,34,34,34,35,35,35,35,/* 57 */
  293.             36,36,36,36,37,37,37,37,38,38,38,38,39,39,39,39,/* 73 */
  294.             40,40,40,40,41,41,41,41,42,42,42,42, /* 85 */
  295.  
  296.             11,11,11,11,11,12,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,/* 26 */
  297.             17,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,/* 43 */
  298.                     43,43,43,43,43,44,44,44,44,44,45,45,45,45,/* 57 */
  299.             46,46,46,46,47,47,47,47,48,48,48,48,49,49,49,49,/* 73 */
  300.             50,50,50,50,51,51,51,51,52,52,52,52, /* 85 */
  301.  
  302.             21,21,21,21,21,22,22,22,22,22,23,23,23,23,24,24,24,24,25,25,25,25,26,26,26,26,/* 26 */
  303.             27,27,27,27,27,28,28,28,28,29,29,29,30,30,30,31,31,/* 43 */
  304.                     53,53,53,53,53,54,54,54,54,54,55,55,55,55,/* 57 */
  305.             56,56,56,56,57,57,57,57,58,58,58,58,59,59,59,59,/* 73 */
  306.             60,60,60,61,61,61,62,62,62,63,63,63 /* 85 */};
  307. long __aligned rev_array[64]={    0,
  308.             1,5,9,13,17,21,25,29,33,38,
  309.             86,90,94,98,102,106,110,114,118,123,
  310.             171,175,179,183,187,191,195,199,203,206,
  311.             208,32,
  312.             44,48,52,56,60,64,68,72,76,83,
  313.             129,133,137,141,145,149,153,157,161,165,
  314.             214,218,222,226,230,234,238,242,246,250,
  315.             250};
  316.     
  317. unsigned short __aligned seed = 7;
  318.  
  319. #ifdef PROTOTYPES
  320.  
  321. int __regargs ReadPix(long,long);
  322. void __regargs FastPix(long,long,long);
  323. void CycleColors(void);
  324. void __regargs HandleEvent(APTR);
  325. void DoAbout(void);
  326. void DoQuit(void);
  327. void __regargs SubDivide(long,long,long,long);
  328. void __regargs adjust(long,long,long,long,long,long);
  329.  
  330. #endif
  331.  
  332.  
  333. void CycleColors()
  334. {
  335.  long __aligned code;
  336.  ULONG __aligned class;
  337.  UWORD __aligned d=0,i,temp;
  338.  USHORT __aligned tpal[PaletteColorCount];
  339.  struct IntuiMessage __aligned *message;
  340.  
  341.  for(i=0;i<PaletteColorCount;i++)
  342.   tpal[i] = Palette[i];
  343.  while (!d)
  344.   {
  345.    temp = tpal[1];
  346.    for(i=2;i<PaletteColorCount;i++)
  347.     {
  348.      tpal[i-1] = tpal[i];
  349.     }
  350.    tpal[(PaletteColorCount-1)] = temp;
  351.    LoadRGB4(&(sC->ViewPort),tpal,PaletteColorCount);
  352.    Delay(6L);
  353.    if ( (message = (struct IntuiMessage *)
  354.     GetMsg(wG->UserPort) ))
  355.     {
  356.     class = message->Class;
  357.     code = message->Code;
  358.     ReplyMsg((struct Message *)message);
  359.     if (class = VANILLAKEY)
  360.      d = 1;
  361.     }
  362.   }
  363.  if (code == ' ')
  364.   LoadRGB4(&(sC->ViewPort),Palette,PaletteColorCount);
  365. }
  366.  
  367. void __regargs adjust(xa,ya,x,y,xb,yb)
  368. long xa,ya,x,y,xb,yb;
  369. {
  370.  long __aligned t1,t2;
  371.  int __aligned pa,pb,pc,pd;
  372.  register long __aligned globalcolor;
  373.  
  374.  if (ReadPix(x,y))
  375.   return;
  376.  pa = xa;
  377.  pb  =xb;
  378.  pc = ya;
  379.  pd = yb;
  380.  globalcolor = randu2(3) * (abs(pa-pb)+abs(pc-pd));
  381.  t1 = unmap(ReadPix(xa,ya));
  382.  t2 = unmap(ReadPix(xb,yb));
  383.  if (!randu2(2))
  384.   {
  385.    globalcolor = -globalcolor;
  386.   }
  387.  globalcolor = ((t1+t2)>>1)+globalcolor;
  388.  globalcolor &= 0xffL;
  389.  globalcolor = maparray[globalcolor];
  390.  FastPix(x,y,globalcolor);
  391. #ifdef DEBUG
  392. temparray[globalcolor]++;
  393. #endif
  394. }
  395.  
  396. void __regargs SubDivide(x1,y1,x2,y2)
  397. long x1,y1,x2,y2;
  398. {
  399.  long __aligned t1,t2,t3,t4;
  400.  ULONG __aligned signals,v;
  401.  struct IntuiMessage __aligned *message;
  402.  long __aligned x,y,class,code;
  403.  APTR __aligned object;
  404.  UWORD __aligned d;
  405.  
  406.  if (((x2-x1)<2L) && ((y2-y1)<2L))
  407.   return;
  408.  if ( (message = (struct IntuiMessage *)
  409.     GetMsg(wG->UserPort) ))
  410.   {
  411.     class = message->Class;
  412.     code = message->Code;
  413.     object = message->IAddress;  /* Gadget */
  414.     ReplyMsg((struct Message *)message);
  415.     if ( class == MENUPICK )    /* MenuItems */
  416.      HandleEvent((APTR)ItemAddress(&MenuList1,code));
  417.     else if (class = VANILLAKEY)
  418.      {
  419.           if ((code == 'c')||(code == 'C'))
  420.        {
  421.         CycleColors();
  422.        }
  423.           else
  424.            {
  425.         d = 0;
  426.         while(!d)
  427.          {
  428.           signals = Wait(WINDOWSIGNAL);
  429.           if (signals & WINDOWSIGNAL)
  430.            while ((message = (struct IntuiMessage *)
  431.                   GetMsg(wG->UserPort)))
  432.             {
  433.              class = message->Class;
  434.              ReplyMsg((struct Message *)message);
  435.              if (class == VANILLAKEY)
  436.               d = 1;
  437.             }
  438.          }
  439.            }
  440.      }
  441.   }
  442.  if (done)
  443.   return;
  444.  x = (x1+x2)>>1;
  445.  y = (y1+y2)>>1;
  446.  if (!ReadPix(x,y))
  447.   {
  448.    t1 = unmap(ReadPix(x1,y1));
  449.    t2 = unmap(ReadPix(x2,y1));
  450.    t3 = unmap(ReadPix(x2,y2));
  451.    t4 = unmap(ReadPix(x1,y2));
  452.    v = ((t1+t2+t3+t4)>>2);
  453.    v = maparray[v];
  454.    FastPix(x,y,v);
  455.   }
  456.  adjust(x1,y1,x,y1,x2,y1);
  457.  adjust(x2,y1,x2,y,x2,y2);
  458.  adjust(x1,y2,x,y2,x2,y2);
  459.  adjust(x1,y1,x1,y,x1,y2);
  460.  SubDivide(x1,y1,x,y);
  461.  SubDivide(x,y1,x2,y);
  462.  SubDivide(x,y,x2,y2);
  463.  SubDivide(x1,y,x,y2);
  464. }
  465.  
  466. void DoAbout()
  467. {
  468.  struct IntuiMessage __aligned *message;
  469.  struct Window __aligned *wG3;
  470.  
  471.  if (!(wG3 = OpenWindow(&NewWindowStructure3)))
  472.  {
  473.   DisplayBeep(0L);
  474.   return;
  475.  }
  476.  PrintIText(wG3->RPort,&IText4,0L,0L);
  477.  WaitPort(wG3->UserPort);
  478.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  479.   ReplyMsg((struct Message *)message);
  480.  CloseWindow(wG3);
  481. }
  482.  
  483. void __regargs HandleEvent(object)
  484. APTR object;
  485. {
  486.   if (object == (APTR)&MenuItem1) { DoAbout(); return; }
  487.   if (object == (APTR)&MenuItem2) { DoQuit(); return; }
  488. }
  489. #define HANDLEEVENT HandleEvent
  490.  
  491. /* end of PowerWindows source generation */
  492.  
  493.  
  494.  
  495. void DoQuit()
  496. {
  497.  done = TRUE;
  498. }
  499.  
  500. /* end of PowerWindows source generation */
  501.  
  502.  
  503. void main(void);
  504. void main()
  505. {
  506.  int __aligned i;
  507. #ifdef DEBUG
  508. int __aligned d;
  509. #endif
  510.     ULONG __aligned code;
  511.     ULONG __aligned class;
  512.     APTR __aligned object;
  513.     ULONG __aligned signals;
  514.     struct IntuiMessage __aligned *message;    /* the message the IDCMP sends us */
  515.  
  516. #ifdef CPU020
  517.  
  518.  struct ExecBase **execbaseptr=(struct ExecBase **)4L;
  519.  UWORD cpuid;
  520.  struct ExecBase *execbase;
  521.  
  522.  execbase = *execbaseptr;
  523.  cpuid = execbase->AttnFlags;
  524.  if (!(cpuid & AFF_68020))
  525.   {
  526.    exit(0);
  527.   }
  528. #endif
  529.  
  530. for(i=8;i<256;i++)
  531.  maparray[i] = i / 8;
  532. for(i=0;i<8;i++)
  533.  maparray[i] = 1;
  534. for(i=0;i<64;i++)
  535.  rev_array[i] = i*8;
  536.         nplanes = DEPTH - 1;
  537.  
  538. #ifdef DEBUG
  539. for(d=0;d<64;d++)temparray[d] = 0;
  540. #endif
  541.     if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 33L)))
  542.          {
  543.            exit(0);
  544.          }
  545.     if(!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 33L)))
  546.          {
  547.            CloseLibrary((struct Library *)IntuitionBase);
  548.            exit(0);
  549.          }
  550.         if (!(myTextFont = OpenFont(&TOPAZ80)))
  551.          {
  552.           CloseLibrary((struct Library *)GfxBase);
  553.           CloseLibrary((struct Library *)IntuitionBase);
  554.           exit(0);
  555.          }
  556.     if (!(sC = OpenScreen(&NewScreenStructure)))
  557.          {
  558.           CloseFont(myTextFont);
  559.           CloseLibrary((struct Library *)GfxBase);
  560.           CloseLibrary((struct Library *)IntuitionBase);
  561.           exit(0);
  562.          }
  563.     LoadRGB4(&(sC->ViewPort),Palette,PaletteColorCount);
  564.     NewWindowStructure3.Screen = NewWindowStructure1.Screen = sC;
  565.     wG = OpenWindow(&NewWindowStructure1);    /* open the window */
  566.     if ( wG == NULL )
  567.     {
  568.       CloseScreen(sC);
  569.           CloseFont(myTextFont);
  570.           CloseLibrary((struct Library *)GfxBase);
  571.           CloseLibrary((struct Library *)IntuitionBase);
  572.           exit(0);
  573.     }
  574.     rpG = wG->RPort;    /* get a rastport pointer for the window */
  575.     SetFont(rpG,myTextFont);
  576.     SetMenuStrip(wG,&MenuList1);    /* attach any Menu */
  577.         SetDrMd(rpG,JAM1);
  578.         for(i=0;i<DEPTH;i++)
  579.          bp[i] = wG->RPort->BitMap->Planes[i];
  580.         ytable[0] = 0;
  581.     for(i=1;i<HEIGHT;i++)
  582.      ytable[i] = ytable[i-1] + rowoffset;
  583.         seed = time(0L);
  584.         signals = (randu2((NUM_COLORS-1))) + 1L;
  585.         FastPix(0L,11L,signals);
  586.         signals = (randu2((NUM_COLORS-1))) + 1L;
  587.         FastPix(319L,11L,signals);
  588.         signals = (randu2((NUM_COLORS-1))) + 1L;
  589.         FastPix(319L,HEIGHT-1L,signals);
  590.         signals = (randu2((NUM_COLORS-1))) + 1L;
  591.         FastPix(0L,HEIGHT-1L,signals);
  592.         SubDivide(0L,11L,319L,HEIGHT-1L);
  593.     DisplayBeep(0L);
  594.     while(!done)
  595.     {
  596.         signals = Wait(WINDOWSIGNAL);
  597.         if (signals & WINDOWSIGNAL)
  598.             while( (message = (struct IntuiMessage *)
  599.                 GetMsg(wG->UserPort) ) != NULL)
  600.             {
  601.                 class = message->Class;
  602.                 code = message->Code;
  603.                 object = message->IAddress;  /* Gadget */
  604.                 ReplyMsg((struct Message *)message);
  605.                 if ( class == MENUPICK )    /* MenuItems */
  606.                  HandleEvent((APTR)ItemAddress(&MenuList1,code));
  607.                 else if (class = VANILLAKEY)
  608.                  {
  609.                       if ((code == 'c')||(code == 'C'))
  610.                    {
  611.                     CycleColors();
  612.                    }
  613.                  }
  614.             }
  615.     }
  616.         CloseWindow(wG);
  617.         CloseFont(myTextFont);
  618.         CloseScreen(sC);
  619.         CloseLibrary((struct Library *)GfxBase);
  620.         CloseLibrary((struct Library *)IntuitionBase);
  621. #ifdef DEBUG
  622. for(d=0;d<64;d++)printf("temp[%d] = %d\n",d,temparray[d]);
  623. #endif
  624. }
  625.